part of 'mcs51.dart';

///将间接地址所指定外部存储器的内容读入累加器(8位地址)
_moveAFromR0(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _iData[m * 8];

  if (t >= RomAndRam.getInstance().ramSize) {
    Utils.getInstance()
        .abort('can\'t ram access $t over ${RomAndRam.getInstance().ramSize} ');
  }
  _acc.value = RomAndRam.getInstance().getRamData(t);
  _syncPsw();
}

_moveAFromR1(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _iData[m * 8 + 1];

  if (t >= RomAndRam.getInstance().ramSize) {
    Utils.getInstance()
        .abort('can\'t ram access $t over ${RomAndRam.getInstance().ramSize} ');
  }
  _acc.value = RomAndRam.getInstance().getRamData(t);
  _syncPsw();
}

///将累加器的内容写入间接地址所指定的外部存储器(8位地址)
_moveFromR0A(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _iData[m * 8];
  if (t >= RomAndRam.getInstance().ramSize) {
    Utils.getInstance()
        .abort('can\'t ram access $t over ${RomAndRam.getInstance().ramSize} ');
  }
  RomAndRam.getInstance().setRamData(t, _acc.value);
}

_moveFromR1A(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _iData[m * 8 + 1];
  if (t >= RomAndRam.getInstance().ramSize) {
    Utils.getInstance()
        .abort('can\'t ram access $t over ${RomAndRam.getInstance().ramSize} ');
  }
  RomAndRam.getInstance().setRamData(t, _acc.value);
}

///将数据指针所指定外部存储器的内容读入累加器(16位地址)
_moveAFromDPTR(List<int> a, int code, int pc) {
  final t = _dph.value * 0x100 + _dpl.value;
  if (t > RomAndRam.getInstance().ramSize) {
    Utils.getInstance()
        .abort('can\'t ram access $t over ${RomAndRam.getInstance().ramSize} ');
  }
  _acc.value = RomAndRam.getInstance().getRamData(t);
  _syncPsw();
}

///将累加器的内容写入数据指针所指定的外部存储器(16位地址)
_moveFromDPTRA(List<int> a, int code, int pc) {
  final t = _dph.value * 0x100 + _dpl.value;
  if (t > RomAndRam.getInstance().ramSize) {
    Utils.getInstance()
        .abort('can\'t ram access $t over ${RomAndRam.getInstance().ramSize} ');
  }
  RomAndRam.getInstance().setRamData(t, _acc.value);
}

///将直接地址的内容压入堆栈区
_pushDirect(List<int> a, int code, int pc) {
  _sp.value += 1;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      _iData[_sp.value] = t.value;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${a.first.toHexString(8)})');
    }
  } else {
    _iData[_sp.value] = _iData[a.first];
  }
}

///从堆栈弹出该直接地址的内容
_popDirect(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      t.value = _iData[_sp.value];
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${a.first.toHexString(8)})');
    }
  } else {
    _iData[a.first] = _iData[_sp.value];
  }
  _sp.value -= 1;
}

///将累加器的值与间接地址的内容互换
_xchAFromR0(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.value = _iData[_iData[m * 8]];
  _iData[_iData[m * 8]] = t;
  _syncPsw();
}

_xchAFromR1(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.value = _iData[_iData[m * 8 + 1]];
  _iData[_iData[m * 8 + 1]] = t;
  _syncPsw();
}

///将累加器的内容与寄存器的内容互换
_xchAR0(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.value = _iData[m * 8];
  _iData[m * 8] = t;
  _syncPsw();
}

_xchAR1(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.value = _iData[m * 8 + 1];
  _iData[m * 8 + 1] = t;
  _syncPsw();
}

_xchAR2(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.value = _iData[m * 8 + 2];
  _iData[m * 8 + 2] = t;
  _syncPsw();
}

_xchAR3(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.value = _iData[m * 8 + 3];
  _iData[m * 8 + 3] = t;
  _syncPsw();
}

_xchAR4(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.value = _iData[m * 8 + 4];
  _iData[m * 8 + 4] = t;
  _syncPsw();
}

_xchAR5(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.value = _iData[m * 8 + 5];
  _iData[m * 8 + 5] = t;
  _syncPsw();
}

_xchAR6(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.value = _iData[m * 8 + 6];
  _iData[m * 8 + 6] = t;
  _syncPsw();
}

_xchAR7(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.value = _iData[m * 8 + 7];
  _iData[m * 8 + 7] = t;
  _syncPsw();
}

///将累加器的值与直接地址的内容互换
_xchADirect(List<int> a, int code, int pc) {
  final acc = _acc.value;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      _acc.value = t.value;
      t.value = acc;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${a.first.toHexString(8)})');
    }
  } else {
    _acc.value = _iData[a.first];
    _iData[a.first] = acc;
  }
  _syncPsw();
}

///将累加器的低4位与间接地址的低4位互换
_xchdAFromR0(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.clearBit(0x0f);
  _acc.value += (_iData[m * 8] & 0x0f);
  (_iData[m * 8] &= ~0x0f);
  _iData[m * 8] += (t & 0x0f);
  _syncPsw();
}

_xchdAFromR1(List<int> a, int code, int pc) {
  final m = _psw.mask(0x18) >> 3;
  final t = _acc.value;
  _acc.clearBit(0x0f);
  _acc.value += (_iData[m * 8 + 1] & 0x0f);
  (_iData[m * 8 + 1] &= ~0x0f);
  _iData[m * 8 + 1] += (t & 0x0f);
  _syncPsw();
}

///将累加器与间接地址的内容相加，结果存回累加器
_addAFromR0(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[_iData[t * 8]];
  bool ac = ((tmp & 0x0f) + (d & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).overSize();
  tmp += d;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addAFromR1(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[_iData[t * 8 + 1]];
  bool ac = ((tmp & 0x0f) + (d & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).overSize();
  tmp += d;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

///将累加器与寄存器的内容相加，结果存回累加器
_addAR0(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8];
  bool ac = ((tmp & 0x0f) + (d & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).overSize();
  tmp += d;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addAR1(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 1];
  bool ac = ((tmp & 0x0f) + (d & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).overSize();
  tmp += d;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addAR2(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 2];
  bool ac = ((tmp & 0x0f) + (d & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).overSize();
  tmp += d;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addAR3(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 3];
  bool ac = ((tmp & 0x0f) + (d & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).overSize();
  tmp += d;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addAR4(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 4];
  bool ac = ((tmp & 0x0f) + (d & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).overSize();
  tmp += d;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addAR5(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 5];
  bool ac = ((tmp & 0x0f) + (d & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).overSize();
  tmp += d;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addAR6(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 6];
  bool ac = ((tmp & 0x0f) + (d & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).overSize();
  tmp += d;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addAR7(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 7];
  bool ac = ((tmp & 0x0f) + (d & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).overSize();
  tmp += d;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

///将累加器与直接地址的内容相加，结果存回累加器
_addADirect(List<int> a, int code, int pc) {
  late final int data;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      data = t.value;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${a.first.toHexString(8)})');
    }
  } else {
    data = _iData[a.first];
  }
  int tmp = _acc.value;
  bool ac = ((tmp & 0x0f) + (data & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(data).overSize();
  tmp += data;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

///将累加器与常数相加，结果存回累加器
_addAData(List<int> a, int code, int pc) {
  final int data = a.first;
  int tmp = _acc.value;
  bool ac = (tmp & 0x0f) + (data & 0x0f) > 0x0f;
  bool ov = tmp.signedAdd(data).overSize();
  tmp += data;
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

///将累加器与间接地址的内容及进位C相加，结果存回累加器
_addcAFromR0(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[_iData[t * 8]];
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((cy + d) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).signedAdd(cy).overSize();
  tmp += (d + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addcAFromR1(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[_iData[t * 8 + 1]];
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((cy + d) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).signedAdd(cy).overSize();
  tmp += (d + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

///将累加器与寄存器的内容及进位C相加，结果存回累加器
_addcAR0(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8];
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((cy + d) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).signedAdd(cy).overSize();
  tmp += (d + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addcAR1(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 1];
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((cy + d) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).signedAdd(cy).overSize();
  tmp += (d + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addcAR2(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 2];
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((cy + d) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).signedAdd(cy).overSize();
  tmp += (d + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addcAR3(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 3];
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((cy + d) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).signedAdd(cy).overSize();
  tmp += (d + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addcAR4(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 4];
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((cy + d) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).signedAdd(cy).overSize();
  tmp += (d + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addcAR5(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 5];
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((cy + d) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).signedAdd(cy).overSize();
  tmp += (d + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addcAR6(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 6];
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((cy + d) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).signedAdd(cy).overSize();
  tmp += (d + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

_addcAR7(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  int tmp = _acc.value;
  int d = _iData[t * 8 + 7];
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((cy + d) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(d).signedAdd(cy).overSize();
  tmp += (d + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

///将累加器与常数及进位C相加，结果存回累加器
_addcAData(List<int> a, int code, int pc) {
  final data = a.first;
  int tmp = _acc.value;
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((data + cy) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(data).signedAdd(cy).overSize();
  tmp += (data + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

///	将累加器与直接地址的内容及进位C相加，结果存回累加器
_addcADirect(List<int> a, int code, int pc) {
  late final int data;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      data = t.value;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${a.first.toHexString(8)})');
    }
  } else {
    data = _iData[a.first];
  }
  int tmp = _acc.value;
  int cy = _psw.mask(0x80) >> 7;
  bool ac = ((tmp & 0x0f) + ((data + cy) & 0x0f)) > 0x0f;
  bool ov = tmp.signedAdd(data).signedAdd(cy).overSize();
  tmp += (data + cy);
  _acc.value = tmp;
  _syncPsw(cy: tmp > 0xff, ac: ac, ov: ov);
}

///将累加器A作十进制调整，若低4位>9或(AC)=1，则低4位值加6；若高4位>9或(C)=1，则高4位值加6；
_daa(List<int> a, int code, int pc) {
  int t = _acc.value;
  int tl = _acc.mask(0x0f);
  if (tl > 9 || _psw.mask(0x40) > 0) {
    t += 0x06;
    if (t > 0xff) _psw.setBit(0x80);
  }
  int th = (t & 0xf0) >> 4;
  if (th > 9 || _psw.mask(0x80) > 0) {
    t += 0x60;
  }
  _acc.value = t;
  _syncPsw(cy: t > 0xff);
}

///SJMP如果跳转到的标号地址距离当前PC所指的地址小于256字节，用SJMP
///AJMP如果跳转到的标号地址距离当前PC所指的地址小于2K字节，用AJMP
///LJMP如果跳转到的标号地址距离当前PC所指的地址小于64K字节，用LJMP
///ACALL是你调用的子程序入口地址距离当前PC所指地址需介于0~2K，LCALL是0～64K

///长跳转(64K内)
_ljmpAddr16(List<int> a, int code, int pc) {
  int addr = a.first * 0x100 + a.last;
  Simulator.getInstance().mcu.pc = addr;
}

/// 绝对跳转2K内 PC 高5位保持不变
_ajmpAddr11(List<int> a, int code, int pc) {
  int addr = (code >> 5) * 0x100 + a.first;
  Simulator.getInstance().mcu.pc = (pc & 0xF800) + addr;
}

///调用2K程序存储器范围内的子程序 PC 高5位保持不变
_acallAddr11(List<int> a, int code, int pc) {
  int addr = (code >> 5) * 0x100 + a.first;
  _sp.value += 1;
  _iData[_sp.value] = pc & 0xff;
  _sp.value += 1;
  _iData[_sp.value] = (pc & 0xff00) >> 8;
  Simulator.getInstance().mcu.pc = (pc & 0xF800) + addr;
}

///调用64K程序存储器范围内的子程序
_lcallAddr16(List<int> a, int code, int pc) {
  int addr = a.first * 0x100 + a.last;
  _sp.value += 1;
  _iData[_sp.value] = pc & 0xff;
  _sp.value += 1;
  _iData[_sp.value] = (pc & 0xff00) >> 8;
  Simulator.getInstance().mcu.pc = addr;
}

///短跳转(2K内)-128～+127字节
_sjmpRel(List<int> a, int code, int pc) {
  Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
}

///跳至累加器的内容加数据指针所指的相关地址
///keil:PC= PC+DPTR(测试是A+DPTR)  PC:010b DPTR:0124 a:0a  -->012e
_jmpFromADPTR(List<int> a, int code, int pc) {
  Simulator.getInstance().mcu.pc = _acc.value + _dph.value * 0x100 + _dpl.value;
}

///将寄存器的内容减1，不等于0则跳至rel所指的相关地址
_djnzR0REL(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  _iData[t * 8]--;
  if (_iData[t * 8] != 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

_djnzR1REL(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  _iData[t * 8 + 1]--;
  if (_iData[t * 8 + 1] != 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

_djnzR2REL(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  _iData[t * 8 + 2]--;
  if (_iData[t * 8 + 2] != 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

_djnzR3REL(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  _iData[t * 8 + 3]--;
  if (_iData[t * 8 + 3] != 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

_djnzR4REL(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  _iData[t * 8 + 4]--;
  if (_iData[t * 8 + 4] != 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

_djnzR5REL(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  _iData[t * 8 + 5]--;
  if (_iData[t * 8 + 5] != 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

_djnzR6REL(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  _iData[t * 8 + 6]--;
  if (_iData[t * 8 + 6] != 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

_djnzR7REL(List<int> a, int code, int pc) {
  final t = _psw.mask(0x18) >> 3;
  _iData[t * 8 + 7]--;
  if (_iData[t * 8 + 7] != 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

///将直接地址的内容减1，不等于0则跳至rel所指的相关地址
_djnzDirectREL(List<int> a, int code, int pc) {
  late final int data;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      t.value--;
      data = t.value;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${a.first.toHexString(8)})');
    }
  } else {
    _iData[a.first]--;
    data = _iData[a.first];
  }
  if (data != 0) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
}

///若直接地址的某位为1，则跳至rel的相关地址，并将该位值清除为0
///位寻址区为内部ram的0x20-0x2f(映射为0x00-0x7F,0x80以上的映射0x80以上被8整除的寄存器)
_jbcREL(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  late bool data;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      data = t.mask(0x01 << t1) > 0;
      if (data) {
        t.clearBit(0x01 << t1);
        Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
      }
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    data = _iData[0x20 + t2] & (0x01 << t1) > 0;
    if (data) {
      _iData[0x20 + t2] &= ~(0x01 << t1);
      Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
    }
  }
}

///若直接地址的某位为1，则跳至rel的相关地址
_jbREL(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  late bool data;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      data = t.mask(0x01 << t1) > 0;
      if (data) {
        Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
      }
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    data = _iData[0x20 + t2] & (0x01 << t1) > 0;
    if (data) {
      Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
    }
  }
}

///若直接地址的某位为0，则跳至rel的相关地址
_jnbREL(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  late bool data;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      data = t.mask(0x01 << t1) > 0;
      if (!data) {
        Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
      }
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    data = _iData[0x20 + t2] & (0x01 << t1) > 0;
    if (!data) {
      Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
    }
  }
}

///若进位C=1则跳至rel的相关地址
_jcREL(List<int> a, int code, int pc) {
  if (_psw.mask(0x80) > 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

///若进位C=0则跳至rel的相关地址
_jncREL(List<int> a, int code, int pc) {
  if (_psw.mask(0x80) == 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

///累加器的内容为0，则跳至rel所指相关地址
_jzREL(List<int> a, int code, int pc) {
  if (_acc.value == 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

///累加器的内容不为0，则跳至rel所指相关地址
_jnzREL(List<int> a, int code, int pc) {
  if (_acc.value > 0) {
    Simulator.getInstance().mcu.pc = pc + a.first.toSigned(8);
  }
}

///将累加器的内容与常数比较，若不相等则跳至rel所指的相关地址
_cjneADataREL(List<int> a, int code, int pc) {
  if (a.first != _acc.value) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  _acc.value < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

///将累加器的内容与直接地址的内容比较，不相等则跳至rel所指的相关地址
_cjneADirectREL(List<int> a, int code, int pc) {
  late final int data;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      data = t.value;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    data = _iData[a.first];
  }
  if (data != _acc.value) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  _acc.value < data ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

///将间接地址的内容与常数比较，若不相等则跳至rel所指的相关地址
_cjneFromR0DataREL(List<int> a, int code, int pc) {
  final m = _iData[_iData[(_psw.mask(0x18) >> 3) * 8]];
  if (m != a.first) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  m < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

_cjneFromR1DataREL(List<int> a, int code, int pc) {
  final m = _iData[_iData[(_psw.mask(0x18) >> 3) * 8 + 1]];
  if (m != a.first) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  m < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

///将寄存器的内容与常数比较，若不相等则跳至rel所指的相关地址
_cjneR0DataREL(List<int> a, int code, int pc) {
  final m = _iData[(_psw.mask(0x18) >> 3) * 8];
  if (m != a.first) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  m < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

_cjneR1DataREL(List<int> a, int code, int pc) {
  final m = _iData[(_psw.mask(0x18) >> 3) * 8 + 1];
  if (m != a.first) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  m < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

_cjneR2DataREL(List<int> a, int code, int pc) {
  final m = _iData[(_psw.mask(0x18) >> 3) * 8 + 2];
  if (m != a.first) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  m < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

_cjneR3DataREL(List<int> a, int code, int pc) {
  final m = _iData[(_psw.mask(0x18) >> 3) * 8 + 3];
  if (m != a.first) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  m < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

_cjneR4DataREL(List<int> a, int code, int pc) {
  final m = _iData[(_psw.mask(0x18) >> 3) * 8 + 4];
  if (m != a.first) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  m < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

_cjneR5DataREL(List<int> a, int code, int pc) {
  final m = _iData[(_psw.mask(0x18) >> 3) * 8 + 5];
  if (m != a.first) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  m < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

_cjneR6DataREL(List<int> a, int code, int pc) {
  final m = _iData[(_psw.mask(0x18) >> 3) * 8 + 6];
  if (m != a.first) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  m < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

_cjneR7DataREL(List<int> a, int code, int pc) {
  final m = _iData[(_psw.mask(0x18) >> 3) * 8 + 7];
  if (m != a.first) {
    Simulator.getInstance().mcu.pc = pc + a.last.toSigned(8);
  }
  m < a.first ? _psw.setBit(0x80) : _psw.clearBit(0x80);
}

///从子程序返回
_ret(List<int> a, int code, int pc) {
  final h = _iData[_sp.value--];
  final l = _iData[_sp.value--];
  Simulator.getInstance().mcu.pc = h * 0x100 + l;
}

///从中断子程序返回
_reti(List<int> a, int code, int pc) {
  final h = _iData[_sp.value--];
  final l = _iData[_sp.value--];
  Simulator.getInstance().mcu.pc = h * 0x100 + l;
}

///清除直接地址的某位为0
_clrBit(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      t.clearBit(0x01 << t1);
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    _iData[0x20 + t2] &= ~(0x01 << t1);
  }
}

///清除进位C为0
_clrC(List<int> a, int code, int pc) {
  _psw.clearBit(0x80);
}

///将直接地址的某位值反相
_cplBit(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      t.filpBit(0x01 << t1);
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    _iData[0x20 + t2] ^= (0x01 << t1);
  }
}

///将进位C的值反相
_cplC(List<int> a, int code, int pc) {
  _psw.filpBit(0x80);
}

///设定直接地址的某位为1
_setbBit(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      t.setBit(0x01 << t1);
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    _iData[0x20 + t2] |= (0x01 << t1);
  }
}

///设定进位C为1
_setbC(List<int> a, int code, int pc) {
  _psw.setBit(0x80);
}

///将进位C与直接地址的某位做“或”的逻辑判断，结果存回进位C
_orlCBit(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      ((_psw.mask(0x80) > 0) || (t.mask(0x01 << t1) > 0))
          ? _psw.setBit(0x80)
          : _psw.clearBit(0x80);
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    ((_psw.mask(0x80) > 0) || ((_iData[0x20 + t2] & (0x01 << t1)) > 0))
        ? _psw.setBit(0x80)
        : _psw.clearBit(0x80);
  }
}

///将进位C与直接地址的某位的反相值做“或”的逻辑判断，结果存回进位C
_orlCFBit(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      ((_psw.mask(0x80) > 0) || !(t.mask(0x01 << t1) > 0))
          ? _psw.setBit(0x80)
          : _psw.clearBit(0x80);
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    ((_psw.mask(0x80) > 0) || !((_iData[0x20 + t2] & (0x01 << t1)) > 0))
        ? _psw.setBit(0x80)
        : _psw.clearBit(0x80);
  }
}

///将进位C与直接地址的某位做“与”的逻辑判断，结果存回进位C
_anlCBit(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      ((_psw.mask(0x80) > 0) && (t.mask(0x01 << t1) > 0))
          ? _psw.setBit(0x80)
          : _psw.clearBit(0x80);
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    ((_psw.mask(0x80) > 0) && ((_iData[0x20 + t2] & (0x01 << t1)) > 0))
        ? _psw.setBit(0x80)
        : _psw.clearBit(0x80);
  }
}

///将进位C与直接地址的某位的反相值做“与”的逻辑判断，结果存回进位C
_anlCFBit(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      ((_psw.mask(0x80) > 0) && !(t.mask(0x01 << t1) > 0))
          ? _psw.setBit(0x80)
          : _psw.clearBit(0x80);
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    ((_psw.mask(0x80) > 0) && !((_iData[0x20 + t2] & (0x01 << t1)) > 0))
        ? _psw.setBit(0x80)
        : _psw.clearBit(0x80);
  }
}

///将进位C的值存入直接地址的某位
_moveBitC(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      _psw.mask(0x80) > 0 ? t.setBit(0x01 << t1) : t.clearBit(0x01 << t1);
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    _psw.mask(0x80) > 0
        ? (_iData[0x20 + t2] |= (0x01 << t1))
        : (_iData[0x20 + t2] &= ~(0x01 << t1));
  }
}

///将直接地址的某位值存入进位C
_moveCBit(List<int> a, int code, int pc) {
  int t1 = a.first % 8;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first - t1);
      t.mask(0x01 << t1) > 0 ? _psw.setBit(0x80) : _psw.clearBit(0x80);
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first - t1).toHexString(8)})');
    }
  } else {
    int t2 = a.first ~/ 8;
    (_iData[0x20 + t2] & (0x01 << t1)) > 0
        ? _psw.setBit(0x80)
        : _psw.clearBit(0x80);
  }
}

///将累加器含进位C右移一位
_rrcA(List<int> a, int code, int pc) {
  final c = _psw.mask(0x80);
  final l = _acc.mask(0x01);
  _acc.value >>= 1;
  c == 0 ? _acc.clearBit(0x80) : _acc.setBit(0x80);
  l == 0 ? _psw.clearBit(0x80) : _psw.setBit(0x80);
  _syncPsw();
}

///将累加器的高4位与低4位的内容交换
_swapA(List<int> a, int code, int pc) {
  final h = _acc.mask(0xf0);
  final l = _acc.mask(0x0f);
  _acc.value = ((l << 4) + (h >> 4));
}

///将累加器的值减间接地址的值减借位C，结果存回累加器
_subbAFromR0(List<int> a, int code, int pc) {
  int d = _iData[_iData[(_psw.mask(0x18) >> 3) * 8]];
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

_subbAFromR1(List<int> a, int code, int pc) {
  int d = _iData[_iData[(_psw.mask(0x18) >> 3) * 8 + 1]];
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

///将累加器的值减去寄存器的值减借位C，结果存回累加器 C AC OV P
_subbAR0(List<int> a, int code, int pc) {
  int d = _iData[(_psw.mask(0x18) >> 3) * 8];
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

_subbAR1(List<int> a, int code, int pc) {
  int d = _iData[(_psw.mask(0x18) >> 3) * 8 + 1];
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

_subbAR2(List<int> a, int code, int pc) {
  int d = _iData[(_psw.mask(0x18) >> 3) * 8 + 2];
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

_subbAR3(List<int> a, int code, int pc) {
  int d = _iData[(_psw.mask(0x18) >> 3) * 8 + 3];
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

_subbAR4(List<int> a, int code, int pc) {
  int d = _iData[(_psw.mask(0x18) >> 3) * 8 + 4];
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

_subbAR5(List<int> a, int code, int pc) {
  int d = _iData[(_psw.mask(0x18) >> 3) * 8 + 5];
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

_subbAR6(List<int> a, int code, int pc) {
  int d = _iData[(_psw.mask(0x18) >> 3) * 8 + 5];
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

_subbAR7(List<int> a, int code, int pc) {
  int d = _iData[(_psw.mask(0x18) >> 3) * 8 + 7];
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

///将累加器的值减直接地址的值减借位C，结果存回累加器
_subbADirect(List<int> a, int code, int pc) {
  late int d;
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      d = t.value;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    d = _iData[a.first];
  }
  int acc = _acc.value;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

///将累加器的值减常数值减借位C，结果存回累加器
_subbAData(List<int> a, int code, int pc) {
  int acc = _acc.value;
  int d = a.first;
  int c = _psw.mask(0x80) >> 7;
  bool ac = (acc & 0x0f) < ((c + d) & 0x0f);
  bool ov = acc.signedSub(c).signedSub(d).overSize();
  _acc.value = acc - c - d;
  _syncPsw(cy: acc < (c + d), ac: ac, ov: ov);
}

///数据指针寄存器值加1，当DPL溢出时，会使DPH加1，不影响任何标志位
_incDptr(List<int> a, int code, int pc) {
  int temp = _dpl.value + 1;
  if (temp > 0xff) _dph.value += 1;
  _dpl.value = temp;
}

///将累加器的值加1,不影响进位标志
_incA(List<int> a, int code, int pc) {
  _acc.value++;
  _syncPsw();
}

///将直接地址的内容加1
_incDirect(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      t.value--;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    _iData[a.first]--;
  }
}

///将间接地址的内容加1
_incFromR0(List<int> a, int code, int pc) {
  _iData[_iData[(_psw.mask(0x18) >> 3)]]++;
}

_incFromR1(List<int> a, int code, int pc) {
  _iData[_iData[(_psw.mask(0x18) >> 3) + 1]]++;
}

///将寄存器的值加l
_incR0(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3)]++;
}

_incR1(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 1]++;
}

_incR2(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 2]++;
}

_incR3(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 3]++;
}

_incR4(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 4]++;
}

_incR5(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 5]++;
}

_incR6(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 6]++;
}

_incR7(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 7]++;
}

///将累加器的值减1
_decA(List<int> a, int code, int pc) {
  _acc.value--;
  _syncPsw();
}

///将直接地址的内容减1
_decDirect(List<int> a, int code, int pc) {}

///将间接地址的内容减1
_decFromR0(List<int> a, int code, int pc) {
  _iData[_iData[(_psw.mask(0x18) >> 3)]]--;
}

_decFromR1(List<int> a, int code, int pc) {
  _iData[_iData[(_psw.mask(0x18) >> 3) + 1]]--;
}

///将寄存器的值减1
_decR0(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3)]--;
}

_decR1(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 1]--;
}

_decR2(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 2]--;
}

_decR3(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 3]--;
}

_decR4(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 4]--;
}

_decR5(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 5]--;
}

_decR6(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 6]--;
}

_decR7(List<int> a, int code, int pc) {
  _iData[(_psw.mask(0x18) >> 3) + 7]--;
}

///将A与B的值相乘，积的低字节存回A，高字节存回B，C OV P 	BA = A * B
_mulAB(List<int> a, int code, int pc) {
  int t = _acc.value * _b.value;
  _acc.value = t;
  _b.value = t >> 8;
  _syncPsw(cy: false, ov: t > 0xff);
}

///将A的值除以B的值，商存回累加器，余数存回B寄存器，CY、OV均被清零 P AB = A / B
_divAB(List<int> a, int code, int pc) {
  if (_b.value == 0) {
    _syncPsw(cy: false, ov: true);
  } else {
    int s = _acc.value ~/ _b.value;
    int y = _acc.value % _b.value;
    _acc.value = s;
    _b.value = y;
    _syncPsw(cy: true, ov: true);
  }
}

///将直接地址的内容与累加器的值做“与”的逻辑判断，结果存回该直接地址
_anlDirectA(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      t.value = (t.value.getBool() && _acc.value.getBool()).toInt();
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    _iData[a.first] =
        (_iData[a.first].getBool() && _acc.value.getBool()).toInt();
  }
}

///将直接地址的内容与常数值做“与”的逻辑判断，结果存回该直接地址
_anlDirectData(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      t.value = (t.value.getBool() && a.last.getBool()).toInt();
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    _iData[a.first] = (_iData[a.first].getBool() && a.last.getBool()).toInt();
  }
}

///将累加器的值与直接地址的内容做“与”的逻辑判断，结果存回累加器
_anlADirect(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      _acc.value = (t.value.getBool() && _acc.value.getBool()).toInt();
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    _acc.value = (_iData[a.first].getBool() && _acc.value.getBool()).toInt();
  }
  _syncPsw();
}

///将累加器的值与常数做“与”的逻辑判断，结果存回累加器
_anlAData(List<int> a, int code, int pc) {
  _acc.value = (a.first.getBool() && _acc.value.getBool()).toInt();
  _syncPsw();
}

///将累加器的值与间接地址的内容做“与”的逻辑判断，结果存回累加器
_anlAFromR0(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[_iData[(_psw.mask(0x18) >> 3)]].getBool() && _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_anlAFromR1(List<int> a, int code, int pc) {
  _acc.value = (_iData[_iData[(_psw.mask(0x18) >> 3) + 1]].getBool() &&
          _acc.value.getBool())
      .toInt();
  _syncPsw();
}

///将累加器的值与寄存器的值做“与”的逻辑判断，结果存回累加器
_anlAR0(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3)].getBool() && _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_anlAR1(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 1].getBool() && _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_anlAR2(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 2].getBool() && _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_anlAR3(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 3].getBool() && _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_anlAR4(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 4].getBool() && _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_anlAR5(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 5].getBool() && _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_anlAR6(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 6].getBool() && _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_anlAR7(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 7].getBool() && _acc.value.getBool())
          .toInt();
  _syncPsw();
}

///将直接地址的内容与累加器的值做“或”的逻辑判断，结果存回该直接地址
_orlDirectA(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      t.value = (t.value.getBool() || _acc.value.getBool()).toInt();
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    _iData[a.first] =
        (_iData[a.first].getBool() || _acc.value.getBool()).toInt();
  }
}

///将直接地址的内容与常数值做“或”的逻辑判断，结果存回该直接地址
_orlDirectData(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      t.value = (t.value.getBool() || a.last.getBool()).toInt();
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    _iData[a.first] = (_iData[a.first].getBool() || a.last.getBool()).toInt();
  }
}

///将累加器的值与直接地址的内容做“或”的逻辑判断，结果存回累加器
_orlADirect(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      _acc.value = (t.value.getBool() || _acc.value.getBool()).toInt();
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    _acc.value = (_iData[a.first].getBool() || _acc.value.getBool()).toInt();
  }
  _syncPsw();
}

///将累加器的值与常数做“或”的逻辑判断，结果存回累加器
_orlAData(List<int> a, int code, int pc) {
  _acc.value = (a.first.getBool() || _acc.value.getBool()).toInt();
  _syncPsw();
}

///将累加器的值与间接地址的内容做“或”的逻辑判断，结果存回累加器
_orlAFromR0(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[_iData[(_psw.mask(0x18) >> 3)]].getBool() || _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_orlAFromR1(List<int> a, int code, int pc) {
  _acc.value = (_iData[_iData[(_psw.mask(0x18) >> 3) + 1]].getBool() ||
          _acc.value.getBool())
      .toInt();
  _syncPsw();
}

///将累加器的值与寄存器的值做“或”的逻辑判断，结果存回累加器
_orlAR0(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3)].getBool() || _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_orlAR1(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 1].getBool() || _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_orlAR2(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 2].getBool() || _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_orlAR3(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 3].getBool() || _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_orlAR4(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 4].getBool() || _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_orlAR5(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 5].getBool() || _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_orlAR6(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 6].getBool() || _acc.value.getBool())
          .toInt();
  _syncPsw();
}

_orlAR7(List<int> a, int code, int pc) {
  _acc.value =
      (_iData[(_psw.mask(0x18) >> 3) + 7].getBool() || _acc.value.getBool())
          .toInt();
  _syncPsw();
}

///将直接地址的内容与累加器的值做“异或”的逻辑判断，结果存回该直接地址
_xrlDirectA(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      t.value = t.value ^ _acc.value;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    _iData[a.first] = _iData[a.first] ^ _acc.value;
  }
}

///将直接地址的内容与常数值做“异或”的逻辑判断，结果存回该直接地址
_xrlDirectData(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      t.value = t.value ^ a.last;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    _iData[a.first] = _iData[a.first] ^ a.last;
  }
}

///将累加器的值与直接地址的内容做“异或”的逻辑判断，结果存回累加器
_xrlADirect(List<int> a, int code, int pc) {
  if (a.first >= 0x80) {
    try {
      final t = _getRegisiter(a.first);
      _acc.value = t.value ^ _acc.value;
    } catch (e) {
      Utils.getInstance()
          .abort('can\'t find regisiter(${(a.first).toHexString(8)})');
    }
  } else {
    _acc.value = _iData[a.first] ^ _acc.value;
  }
  _syncPsw();
}

///将累加器的值与常数做“异或”的逻辑判断，结果存回累加器
_xrlAData(List<int> a, int code, int pc) {
  _acc.value = a.first ^ _acc.value;
  _syncPsw();
}

///将累加器的值与间接地址的内容做“异或”的逻辑判断，结果存回累加器
_xrlAFromR0(List<int> a, int code, int pc) {
  _acc.value = _iData[_iData[(_psw.mask(0x18) >> 3)]] ^ _acc.value;
  _syncPsw();
}

_xrlAFromR1(List<int> a, int code, int pc) {
  _acc.value = _iData[_iData[(_psw.mask(0x18) >> 3) + 1]] ^ _acc.value;
  _syncPsw();
}

///将累加器的值与寄存器的值做“异或”的逻辑判断，结果存回累加器
_xrlAR0(List<int> a, int code, int pc) {
  _acc.value = _iData[(_psw.mask(0x18) >> 3)] ^ _acc.value;
  _syncPsw();
}

_xrlAR1(List<int> a, int code, int pc) {
  _acc.value = _iData[(_psw.mask(0x18) >> 3) + 1] ^ _acc.value;
  _syncPsw();
}

_xrlAR2(List<int> a, int code, int pc) {
  _acc.value = _iData[(_psw.mask(0x18) >> 3) + 2] ^ _acc.value;
  _syncPsw();
}

_xrlAR3(List<int> a, int code, int pc) {
  _acc.value = _iData[(_psw.mask(0x18) >> 3) + 3] ^ _acc.value;
  _syncPsw();
}

_xrlAR4(List<int> a, int code, int pc) {
  _acc.value = _iData[(_psw.mask(0x18) >> 3) + 4] ^ _acc.value;
  _syncPsw();
}

_xrlAR5(List<int> a, int code, int pc) {
  _acc.value = _iData[(_psw.mask(0x18) >> 3) + 5] ^ _acc.value;
  _syncPsw();
}

_xrlAR6(List<int> a, int code, int pc) {
  _acc.value = _iData[(_psw.mask(0x18) >> 3) + 6] ^ _acc.value;
  _syncPsw();
}

_xrlAR7(List<int> a, int code, int pc) {
  _acc.value = _iData[(_psw.mask(0x18) >> 3) + 7] ^ _acc.value;
  _syncPsw();
}

//将累加器的值左移一位
_rlA(List<int> a, int code, int pc) {
  final h = _acc.mask(0x80);
  _acc.value <<= 1;
  if (h.getBool()) {
    _acc.setBit(0x01);
  }
}

///将累加器的值右移一位
_rrA(List<int> a, int code, int pc) {
  final l = _acc.mask(0x01);
  _acc.value >>= 1;
  if (l.getBool()) {
    _acc.setBit(0x80);
  }
}

///将累加器含进位C左移一位
_rlcA(List<int> a, int code, int pc) {
  final c = _psw.mask(0x80);
  final h = _acc.mask(0x80);
  _acc.value <<= 1;
  c == 0 ? _acc.clearBit(0x01) : _acc.setBit(0x01);
  h == 0 ? _psw.clearBit(0x80) : _psw.setBit(0x80);
  _syncPsw();
}

///清除累加器的值为0
_clrA(List<int> a, int code, int pc) {
  _acc.value = 0;
  _syncPsw();
}

///将累加器的值反相
_cplA(List<int> a, int code, int pc) {
  _acc.value = ~_acc.value;
}
